package a.j;

import a.d.w;
import a.e.b.b.n;
import a.e.b.b.t;
import a.e.b.c.eb;
import a.e.b.c.o;
import a.e.b.c.v;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class rd
  implements de
{
  public static final byte a = 1;
  public static final byte b = 2;
  public static final byte c = 3;
  public static final byte d = 4;
  public static final byte e = 5;
  private static final rd f = new rd();
  public static final ee g = f.a(new w(0.0D, 0.0D));
  public static final ee h = f.a(new w(-0.5D, 0.0D));
  public static final ee i = f.a(new w(0.5D, 0.0D));
  public static final ee j = f.a(new w(0.0D, -0.5D));
  public static final ee k = f.a(new w(0.0D, 0.5D));
  public static final ee l = f.a(new w(-0.5D, -0.5D));
  public static final ee m = f.a(new w(0.5D, -0.5D));
  public static final ee n = f.a(new w(0.5D, 0.5D));
  public static final ee o = f.a(new w(-0.5D, 0.5D));
  private static final double p = 1.0E-008D;
  private byte q = 5;
  static Class r;
  static Class s;
  public static boolean t;
  
  public byte a()
  {
    return this.q;
  }
  
  public void a(byte paramByte)
  {
    if (!ld.E) {}
    switch (paramByte)
    {
    case 1: 
    case 2: 
    case 3: 
    case 4: 
    case 5: 
      this.q = paramByte;
      if (!ld.D) {
        break;
      }
    default: 
      throw new IllegalArgumentException("Invalid policy: " + paramByte);
    }
  }
  
  public w a(jd paramjd, ee paramee)
  {
    a_ locala_ = c(paramee);
    ld localld = paramjd.b();
    return new w(localld.A() + locala_.b * localld.c(), localld.B() + locala_.c * localld.d());
  }
  
  public ee a(ld paramld, w paramw)
  {
    if (!ld.E) {}
    switch (a())
    {
    case 1: 
      return h(paramld, paramw);
    case 2: 
      return c(paramld, paramw);
    case 3: 
      return e(paramld, paramw);
    case 4: 
      return g(paramld, paramw);
    case 5: 
      return i(paramld, paramw);
    }
    throw new IllegalStateException("Invalid policy: " + a());
  }
  
  private ee c(ld paramld, w paramw)
  {
    if (paramld == null) {
      return a(l);
    }
    return i(paramld, a(paramld, paramw, false));
  }
  
  private ee e(ld paramld, w paramw)
  {
    if (!ld.E) {
      if (paramld == null) {
        return a(g);
      }
    }
    w localw = a(paramld, paramw, false);
    if (a(paramw, localw) > a(paramw, new w(paramld.A(), paramld.B()))) {
      return a(g);
    }
    return i(paramld, localw);
  }
  
  private ee g(ld paramld, w paramw)
  {
    if (paramld == null) {
      return a(g);
    }
    return i(paramld, a(paramld, paramw, true));
  }
  
  private static w a(ld paramld, w paramw, boolean paramBoolean)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    double d1 = paramld.a();
    double d2 = paramld.b();
    double d3 = paramld.c();
    double d4 = paramld.d();
    double d5 = paramw.a();
    if (!bool2)
    {
      if (d5 < d1)
      {
        if (bool2) {
          break label89;
        }
        d5 = d1;
        if (!bool1) {}
      }
      else
      {
        if (bool2) {
          break label89;
        }
      }
    }
    else if (d5 > d1 + d3) {
      d5 = d1 + d3;
    }
    label89:
    double d6 = paramw.b();
    if (!bool2) {
      if (d6 < d2)
      {
        d6 = d2;
        if (bool2) {
          break label142;
        }
        if (!bool1) {
          break label141;
        }
      }
    }
    if (!bool2) {
      if (d6 > d2 + d4) {
        d6 = d2 + d4;
      }
    }
    label141:
    if (paramBoolean) {
      label142:
      return new w(d5, d6);
    }
    double d7 = d5 - paramld.A();
    double d8 = d6 - paramld.B();
    if (!bool2) {}
    int i1 = Math.abs(Math.abs(d7) - d3 * 0.5D) < 1.0E-008D ? 1 : 0;
    if (!bool2) {}
    int i2 = Math.abs(Math.abs(d8) - d4 * 0.5D) < 1.0E-008D ? 1 : 0;
    double d9 = (bool2) || (d7 > 0.0D) ? d1 + d3 : d1;
    double d10 = (bool2) || (d8 > 0.0D) ? d2 + d4 : d2;
    if (!bool2) {
      if (i1 == 0)
      {
        if (bool2) {
          break label395;
        }
        if (i2 == 0) {
          break label370;
        }
      }
    }
    if (!bool2) {
      if (i1 != 0)
      {
        if (bool2) {
          break label343;
        }
        if (i2 != 0) {
          return new w(d9, d10);
        }
      }
    }
    if (i1 != 0) {
      label343:
      return new w(d9, d6);
    }
    return new w(d5, d10);
    label370:
    if (d3 - 2.0D * Math.abs(d7) < d4 - 2.0D * Math.abs(d8)) {
      return new w(d9, d6);
    }
    label395:
    return new w(d5, d10);
  }
  
  private ee h(ld paramld, w paramw)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    if (!bool2) {
      if (paramld == null) {
        return a(g);
      }
    }
    double d1 = paramld.A();
    double d2 = paramld.c();
    double d3 = paramld.B();
    double d4 = paramld.d();
    a_[] arrayOfa_ = { c(g), c(h), c(i), c(j), c(k), c(l), c(m), c(n), c(o) };
    double d5 = (1.0D / 0.0D);
    int i1 = -1;
    int i2 = 0;
    do
    {
      if (i2 >= arrayOfa_.length) {
        break;
      }
      if (bool1) {
        break label263;
      }
      a_ locala_ = arrayOfa_[i2];
      w localw = new w(d1 + locala_.b * d2, d3 + locala_.c * d4);
      double d6 = a(localw, paramw);
      if (!bool2)
      {
        if (d5 > d6)
        {
          d5 = d6;
          i1 = i2;
        }
        i2++;
      }
    } while (!bool1);
    label263:
    return new a_(this, arrayOfa_[i1].b, arrayOfa_[i1].c);
  }
  
  private static double a(w paramw1, w paramw2)
  {
    double d1 = paramw1.a() - paramw2.a();
    double d2 = paramw1.b() - paramw2.b();
    return d1 * d1 + d2 * d2;
  }
  
  private ee i(ld paramld, w paramw)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    if (!bool2) {
      if (paramld == null) {
        return a(g);
      }
    }
    double d1 = paramld.a();
    double d2 = paramld.c();
    double d3 = paramld.b();
    double d4 = paramld.d();
    if (!bool2) {
      if (d2 > 0.0D)
      {
        d5 = (paramw.a() - d1 - d2 * 0.5D) / d2;
        if (bool2) {
          break label102;
        }
        if (!bool1) {
          break label93;
        }
      }
    }
    double d5 = 0.0D;
    label93:
    if (!bool2) {
      if (d4 > 0.0D)
      {
        label102:
        d6 = (paramw.b() - d3 - d4 * 0.5D) / d4;
        if (bool2) {
          break label141;
        }
        if (!bool1) {
          break label137;
        }
      }
    }
    double d6 = 0.0D;
    label137:
    label141:
    if ((bool2) || ((d5 == 0.0D) && (d6 == 0.0D))) {
      return a(g);
    }
    return new a_(this, d5, d6);
  }
  
  public ee a(w paramw)
  {
    return new a_(this, paramw.a(), paramw.b());
  }
  
  private a_ a(ee paramee)
  {
    a_ locala_ = c(paramee);
    return new a_(this, locala_.b, locala_.c);
  }
  
  static a_ c(ee paramee)
  {
    try
    {
      return (a_)paramee;
    }
    catch (ClassCastException localClassCastException)
    {
      throw new IllegalArgumentException("Invalid model parameter type.");
    }
  }
  
  static Class a(String paramString)
  {
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
  
  public static class b_
    implements v, n
  {
    private static final String a = "NodeScaledPortLocationModel";
    public static int b;
    
    public void a(eb parameb)
      throws a.e.b.c.a
    {
      Object localObject = parameb.a();
      if (a(localObject))
      {
        a.e.b.c.cb localcb = parameb.e();
        localcb.a("NodeScaledPortLocationModel", "http://www.yworks.com/xml/graphml");
        a((rd.a_)localObject, localcb, parameb.d());
        localcb.b();
        parameb.a(true);
      }
    }
    
    public void a(ee paramee, a.e.b.c.cb paramcb, o paramo)
      throws a.e.b.c.a
    {
      rd.a_ locala_ = rd.c(paramee);
      String str = a(locala_.a.a());
      if (!ld.E)
      {
        if (str != null) {
          paramcb.c("portLocationPolicy", str);
        }
        paramcb.a("ratioX", locala_.b);
        paramcb.a("ratioY", locala_.c);
      }
    }
    
    private boolean a(Object paramObject)
    {
      boolean bool = ld.E;
      if (paramObject != null)
      {
        if (!bool) {}
        if ((rd.r == null ? (rd.r = rd.a("a.j.rd$a_")) : rd.r) == paramObject.getClass())
        {
          de localde = ((rd.a_)paramObject).a();
          if (localde != null) {
            if (bool) {}
          }
          return (rd.s == null ? (rd.s = rd.a("a.j.rd")) : rd.s) == localde.getClass();
        }
      }
      return false;
    }
    
    private static String a(byte paramByte)
    {
      switch (paramByte)
      {
      case 1: 
        return "POLICY_DISCRETE";
      case 2: 
        return "POLICY_BOUNDARY";
      case 3: 
        return "POLICY_BOUNDARY_CENTER";
      case 4: 
        return "POLICY_BOUNDARY_INSIDE";
      case 5: 
        return "POLICY_FREE";
      }
      return null;
    }
    
    public void a(a.e.b.b.cb paramcb)
      throws a.e.b.b.a
    {
      boolean bool2 = ld.E;
      boolean bool1 = ld.D;
      Node localNode1 = paramcb.e();
      if ((bool2) || (b(localNode1)))
      {
        Node localNode2 = localNode1.getFirstChild();
        do
        {
          if (localNode2 == null) {
            break;
          }
          if (!bool2) {
            if (a(localNode2))
            {
              paramcb.a(a(localNode2.getAttributes(), paramcb.d()));
              if (!bool2) {
                if (!bool1) {
                  break;
                }
              }
            }
            else
            {
              localNode2 = localNode2.getNextSibling();
            }
          }
        } while (!bool1);
      }
    }
    
    public ee a(NamedNodeMap paramNamedNodeMap, t paramt)
      throws a.e.b.b.a
    {
      boolean bool = ld.E;
      double d1 = 0.0D;
      Node localNode1 = paramNamedNodeMap.getNamedItem("ratioX");
      if (!bool) {
        if (localNode1 == null) {
          throw new a.e.b.b.a("Missing attribute ratioX for element NodeScaledPortLocationModel.");
        }
      }
      d1 = Double.parseDouble(localNode1.getNodeValue());
      double d2 = 0.0D;
      Node localNode2 = paramNamedNodeMap.getNamedItem("ratioY");
      if (!bool) {
        if (localNode2 == null) {
          throw new a.e.b.b.a("Missing attribute ratioY for element NodeScaledPortLocationModel.");
        }
      }
      d2 = Double.parseDouble(localNode2.getNodeValue());
      rd localrd = b(paramNamedNodeMap, paramt);
      Node localNode3 = paramNamedNodeMap.getNamedItem("portLocationPolicy");
      if ((bool) || (localNode3 != null))
      {
        String str = localNode3.getNodeValue().toUpperCase();
        try
        {
          localrd.a(a(str));
        }
        catch (IllegalArgumentException localIllegalArgumentException)
        {
          throw new a.e.b.b.a("Unsupported portLocationPolicy value: " + str);
        }
      }
      return new rd.a_(localrd, d1, d2);
    }
    
    protected rd b(NamedNodeMap paramNamedNodeMap, t paramt)
      throws a.e.b.b.a
    {
      return new rd();
    }
    
    protected boolean a(Node paramNode)
    {
      boolean bool = ld.E;
      if ((bool) || (d(paramNode))) {
        if (bool) {}
      }
      return "NodeScaledPortLocationModel".equals(paramNode.getLocalName());
    }
    
    public static boolean b(Node paramNode)
    {
      boolean bool = ld.E;
      if ((bool) || (d(paramNode))) {
        if (bool) {}
      }
      return "Geometry".equals(paramNode.getLocalName());
    }
    
    private static boolean d(Node paramNode)
    {
      boolean bool = ld.E;
      if ((bool) || (paramNode.getNodeType() == 1)) {
        if (bool) {}
      }
      return "http://www.yworks.com/xml/graphml".equals(paramNode.getNamespaceURI());
    }
    
    private static byte a(String paramString)
    {
      boolean bool = ld.E;
      if (!bool) {
        if ("POLICY_DISCRETE".equals(paramString)) {
          return 1;
        }
      }
      if (!bool) {
        if ("POLICY_BOUNDARY".equals(paramString)) {
          return 2;
        }
      }
      if (!bool) {
        if ("POLICY_BOUNDARY_CENTER".equals(paramString)) {
          return 3;
        }
      }
      if (!bool) {
        if ("POLICY_BOUNDARY_INSIDE".equals(paramString)) {
          return 4;
        }
      }
      if ((bool) || ("POLICY_FREE".equals(paramString))) {
        return 5;
      }
      throw new IllegalArgumentException("Unsupported portLocationPolicy value: " + paramString);
    }
  }
  
  static final class a_
    implements ee
  {
    final rd a;
    final double b;
    final double c;
    
    a_(rd paramrd, double paramDouble1, double paramDouble2)
    {
      this.a = paramrd;
      this.b = paramDouble1;
      this.c = paramDouble2;
    }
    
    public de a()
    {
      return this.a;
    }
  }
}


/* Location:           E:\idea\
 * Qualified Name:     a.j.rd
 * JD-Core Version:    0.7.0.1
 */